package com.bitrate.dagger.sdk.websocket.client;

import java.util.HashMap;
import java.util.Map;

import com.bitrate.dagger.sdk.websocket.enums.SystemPushType;
import com.bitrate.dagger.sdk.websocket.request.WebSocketRequest;
import com.bitrate.dagger.sdk.websocket.sender.WebSocketSender;

/**
 * WebSocket推送客户端
 */
public class WebSocketClient {

	private WebSocketSender wsSender;

	public WebSocketClient(String host, String commonKey) {
		this.wsSender = new WebSocketSender(host, commonKey);
	}

	public String push(WebSocketRequest request, String... channelArr) {
		return this.wsSender.push(request, channelArr);
	}

	public static void main(String[] args) {
		WebSocketClient client = new WebSocketClient("push.boleec.com", "DPush-4b35236b6cff4d21a1406c68bee666a9");
		WebSocketRequest request = new WebSocketRequest();
		request.setType(SystemPushType.HEART_BEAT);
		request.setContent("优惠券内容");
		Map<String, String> extraMap = new HashMap<String, String>();
		extraMap.put("couponId", "789992771");
		extraMap.put("timeRule", "2020/02/14 9:00~~~020/02/14 9:00");
		request.setExtraMap(extraMap);
		client.push(request, "1295985097169833984");
	}
}
